package com.xr.blackhoole.mvc.utils;

import java.util.Random;

public class WormholeCommonUtils {
    /**
     * 数组随机乱序
     *
     * @param orginArray
     * @param <T>
     * @return
     */
    public static <T> T[] shuffle(T[] orginArray) {
        if (null == orginArray) {
            return orginArray;
        }
        Random random = new Random();
        int size = orginArray.length;
        for (int i = 0; i < size; i++) {
            int p = random.nextInt(size);
            T tmp = orginArray[i];
            orginArray[i] = orginArray[p];
            orginArray[p] = tmp;
        }
        random = null;
        return orginArray;
    }

    /**
     * 延时操作
     *
     * @param delayTime
     */
    public static void delay(long delayTime) {
        if (delayTime > 0) {
            try {
                Thread.sleep(delayTime);
            } catch (InterruptedException e) {
            }
        }
    }
}